package com.example.lanqiaodemo1.java15;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
public class WorkerManage {
    public float getAverageWage(List<Worker> list) {
        float averageWage = 0, sumWage = 0;
        for (int i = 0; i < list.size(); i++)
            sumWage = sumWage + list.get(i).getWage();
        averageWage = sumWage / list.size();
        return averageWage;
    }

    public static void main(String[] args) throws ParseException {
        List<Worker> list = new ArrayList();
        Scanner sc = new Scanner(System.in);
        SimpleDateFormat format = new SimpleDateFormat("yyyy-mm-dd");
        for (int i = 0; i < 5; i++) {
            String name = sc.next();
            String birthday = sc.next();
            float wage = sc.nextFloat();
            list.add(new Worker(name, format.parse(birthday), wage));
        }
        sc.close();
        
        
        Worker workerTemp = new Worker("张三", format.parse("1996-8-22"), 3000);
        list.set(2, workerTemp);
        Collections.reverse(list);
        for (int i = 0; i < list.size(); i++)
            list.get(i).print();

        WorkerManage workerManage = new WorkerManage();
        float averageWage = workerManage.getAverageWage(list);
        System.out.println("averageWage=" + averageWage);

    }

}

class Worker {
    private String name;
    private Date birthday;
    private float wage;

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Date getBirthday() {
        return birthday;
    }
    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }
    public float getWage() {
        return wage;
    }
    public void setWage(float wage) {
        this.wage = wage;
    }

    public Worker(String name, Date birthday, float wage) {
        this.name = name;
        this.birthday = birthday;
        this.wage = wage;
    }
    public Worker() {
        this.name =" ";
        this.birthday = null;
        this.wage = 0;
    }

    public void print() {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-mm-dd");
        System.out.println("name:" + name + "  birthday:" + format.format(birthday) + "  wage:" + wage);
    }
}
